<?php

/**
 * File Description
 * 
 * Kao: PHP Web Framework <http://kao.byhuy.com/>.
 * Copyright 2008, Huy Nguyen <http://www.byhuy.com/>.
 * 
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */


abstract class Kao_Router_Abstract
{
    protected $_requestUrl = null;
    
    
    /**
     * Abstract route function
     */
    abstract public function route();
    
    /**
     * Returns request url
     */
    public function getRequestUrl()
    {
        if (null === $this->_requestUrl)
        {
            $this->setRequestUrl();
        }
        return $this->_requestUrl;
    }

    /**
     * Sets request URL.
     * 
     * @param string $url
     */
    public function setRequestUrl($url = null)
    {
        if (null === $url)
        {
            $url = $_SERVER['REQUEST_URI'];
            $pos = strpos($url, '?');
            if ((int) $pos > 0)
            {
                $url = substr($url, 0, $pos);
            }
        }
        $this->_requestUrl = $url;
    }
}



